package pc15;

import java.util.Scanner;

public class J10SungJuk {

	//return method
	public static void main(String[] args) {
		/* 주의: Scanner 클래스를 이용해서 입력처리 후
		 * close()를 하게 되면 다시 Scanner 생성 불가*/
		
		String name;
		int kor, eng, mat;
		int tot;
		double avg;
		char grd;
		String result="";
		
		name = inputName(makeScanner());
		kor = inputKor(makeScanner());
		eng = inputEng(makeScanner());
		mat = inputMat(makeScanner());
		
		tot = getTotal(kor, eng, mat);
		avg = getAvg(tot);
		grd = getGrd(avg);
		
		result += "-------"+name+"학생의 결과값은 ------- \n";
		result += "합계:"+tot+",평균:"+avg+",학점:"+grd;
		System.out.println(result);
	}//main

	private static int inputMat(Scanner sc) {
		System.out.print("수학: "); 
		return  sc.nextInt();
	}

	private static int inputEng(Scanner sc) {
		System.out.print("영어: "); 
		return sc.nextInt();
	}

	private static int inputKor(Scanner sc) {
		System.out.print("국어: "); 
		return sc.nextInt();
	}

	private static String inputName(Scanner sc) {
		System.out.print("이름: "); 
		return sc.next();
	}

	// Scanner 생성
	public static Scanner makeScanner(){
		Scanner sc = new Scanner(System.in);
		return sc;
	}
	
	// Scanner 종료
	public static void closeScanner(Scanner sc){
		if(sc!=null) sc.close();
	}
	
	private static char getGrd(double avg) {
		char grd;
		switch ((int)avg/10) {
		case 10:
		case 9: grd = '수';	break;
		case 8: grd = '우';	break;
		case 7: grd = '미';	break;
		case 6: grd = '양';	break;
		default: grd = '가';
		}
		return grd;
	}

	private static double getAvg(int tot) {
		return (double)tot/3;
	}

	private static int getTotal(int kor, int eng, int mat) {
		return (kor+eng+mat);
	}
	
}//class
